<template>
  <div>
    <!-- 头部导航 -->
    <van-nav-bar
      title="管理分组"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />

    <van-cell-group  inset>
      <van-cell center :title="itemtype.itemTypeName" label="" v-for="(itemtype, index) in sidebarList" :key="index">
        <van-button round  type="default" size="small" @click="addItem(itemtype)">新建商品</van-button>
        <van-button class="button" round  type="default" size="small">删除</van-button>
      </van-cell>
    </van-cell-group>

    <van-tabbar v-model="activei" active-color="black">
      <van-tabbar-item>
        <template>
          <span>排序管理</span>
        </template>
      </van-tabbar-item>
      <van-tabbar-item @click="onClick">
        <template>
          <span>新建分组</span>
        </template>
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import axios from 'axios';
export default {
  name: 'GanagementGroup',
  data(){
    return{
      sidebarList:[],
      activei:0,
      // 商家信息
      shop:this.$store.state.shop,
    };
  },
  methods:{
    //点击跳转携带值
    addItem(itemType){
      this.$router.push({
        name:"newgroup",
        query:{
          itemType:itemType
        }
      })
    },
    //点击取消
    onClickLeft() {
      this.$router.push({
	      name:'item'
    })
    },
    //点击新建分组
    onClick(){
      this.$router.push({
	      name:'managementGroupNewgroup'
    })
    },
    //通过商家id查询全部商品类型
    getItemTypeByShopId(){
      axios.get("/api/item/itemType/getItemTypeListByShopId",
      {
        params:{
          shopId:this.shop.shopId
        }
      }).then(result =>{
        this.sidebarList = result.data.data
      })
    },
  },
  mounted() {
    this.getItemTypeByShopId()
  },
  
}
</script>
  
<style scoped>
  .button{
    margin-left: 15px;
  }
</style>
